import dayjs from 'dayjs'

export function customScheduleTime(obj = {}) {
  const {
    start = '08:00',
    end = '18:00',
    distance = 30,
    type = 'm'
  } = obj
  const startDateStr = `${dayjs().format('YYYY-MM-DD')} ${start}`
  const endDateStr = `${dayjs().format('YYYY-MM-DD')} ${end}`
  const result = []

  let date = dayjs(startDateStr)
  while (date.isBefore(dayjs(endDateStr))) {
    result.push({
      key: `${date.format('HH:mm')}-${date.add(distance, type).format('HH:mm')}`,
      start: `${date.format('HH:mm')}`,
      end: `${date.add(distance, type).format('HH:mm')}`
    })
    date = date.add(distance, type)
  }
  return result
}